const globalData = getApp().globalData;
const getUserInfo = globalData.getUserInfo;
const wxApi = globalData.wxApi;
const logger = globalData.logger;

const INTERGRATION_PAGE = 'integration/integration';
const COLECTION_PAGE = '../topics/topics';
const ABOUTUS_PAGE = 'aboutus/aboutus';
const FEEDBACK_PAGE = 'feedback/feedback';
const SETTINGS_PAGE = 'settings/settings';
const INVITATION_PAGE = '../invitation/invitation';
Page({
  data: {
    userInfo: null,
    phoneNumber: "021-58327007"
  },
  onShow() {
    this.getUserInfo();
  },
  onLoad: function () {

  },
  onReady: function () {
  },
  getUserInfo: function(e) {
    let self = this;
    let userInfo = null;
    
    userInfo = getUserInfo();
    if ( userInfo ) {
      self.setData( {
        userInfo: userInfo
      } )
    }
  },
  /**
   * 前往 积分 页面
   */
  goIntegration() {
    wxApi.navigateTo( INTERGRATION_PAGE );
  },
  /**
   * 前往 收藏 页面
   */
  goCollection() {
    wxApi.navigateTo( COLECTION_PAGE, {
      collectParam: true
    });
  },
  /**
   * 前往 关于我们 页面
   */
  goAboutus() {
    wxApi.navigateTo( ABOUTUS_PAGE );
  },
  /**
   * 邀请
   */
  goInvitation() {
    wxApi.navigateTo( INVITATION_PAGE );
  },
  /**
   * 前往 反馈 页面
   */
  goFeedback() {
    wxApi.navigateTo( FEEDBACK_PAGE );
  },
  /**
   * 前往 设置 页面
   */
  goSettings() {
    wxApi.navigateTo( SETTINGS_PAGE );
  },
  /**
   * 拨打电话
   */
  callPhone() {
    wx.makePhoneCall({
      phoneNumber: this.data.phoneNumber
    })
  }
})